

// 全局的过滤器或者指令


import Vue from 'vue'
import moment from 'moment'

Vue.filter("dateFormat",(value,type)=>{
    if(!value) return value
    type = type || "MMM Do YY";
    return moment(value).format(type);
})


Vue.filter("dateFormat2",(value,index)=>{
    if(!value) return value
    var nowTime = new Date();
    var nowDay = nowTime.getDate();  //

    var time = new Date(value)
    var month = time.getMonth()+1;
    var day = time.getDate()
    var week = time.getDay()
    var arr = ['周日',"周一","周二","周三","周四","周五","周六"]
    var text = arr[week]
    if(nowDay==day){
        text = '今天'
    }
    if(nowDay+1==day){
        text = '明天'
    }
    if(nowDay+2==day){
        text = '后天'
    }
    return `${text}${month}月${day}日`
})